package com.pingan.haofang.searchcloud.batch.monitor;

import com.pingan.haofang.searchcloud.batch.common.Batch;
import com.pingan.haofang.searchcloud.monitor.service.DashboardResourceInfoService;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @author EX-LIUXIANWEN001
 * @date 2018/10/30
 * @since 1.0.0
 */
@Batch(value = "resourceAcquisitionTask", permanent = true)
@ConditionalOnProperty("resourceAcquisitionTask")
public class ResourceAcquisitionRunner {

    @Autowired
    private DashboardResourceInfoService dashboardResourceInfoService;


    Logger LOG = LoggerFactory.getLogger(ResourceAcquisitionRunner.class);
    /**
     * 定时采集硬件信息 节点健康率  硬盘使用率
     */
    @Scheduled(cron = "${dashboard.resource.acquisition}")
    public void refresh() {
        LOG.info(new Date().toString());

        dashboardResourceInfoService.saveDashboardResourceInfo();

        LOG.info(new Date().toString());
    }


}
